﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="WindowsColors.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Color x:Key="Dialog_CloseButton_Background" A="255" R="89" G="89" B="89"/>
    <Color x:Key="Dialog_CloseButton_BorderBrush" A="255" R="51" G="51" B="51"/>
    <Color x:Key="Dialog_CloseButton_Background_Move" A="255" R="170" G="170" B="170"/>
    <Color x:Key="Dialog_CloseButton_BorderBrush_Move" A="255" R="66" G="66" B="66"/>
    <Color x:Key="Dialog_CloseButton_Background_Pressed" A="255" R="66" G="66" B="66"/>
    <Color x:Key="Dialog_CloseButton_BorderBrush_Pressed" A="255" R="0" G="0" B="0"/>

    <Style x:Key="DialogStyle" TargetType="{x:Type Window}">
        <Setter Property="Foreground">
        	 <Setter.Value>
                <SolidColorBrush Color="{StaticResource Application_Dialog_Foreground}"/>
        	 </Setter.Value>
		</Setter>
		<Setter Property="Template" Value="{DynamicResource DialogTemplate}"/>
	</Style>
    
	<ControlTemplate x:Key="DialogTemplate" TargetType="{x:Type Window}">
    	<DockPanel Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
    		<Border x:Name="HeadBar" BorderThickness="2,2,2,0" DockPanel.Dock="Top" Height="24">
    			<Border.Background>
    				<SolidColorBrush Color="{StaticResource Application_Dialog_HeaderBrush}"/>
    			</Border.Background>
    			<Border.BorderBrush>
    				<SolidColorBrush Color="{StaticResource Application_Dialog_BorderBrush}"/>
    			</Border.BorderBrush>
    			<Grid>
    				<Grid.ColumnDefinitions>
    					<ColumnDefinition Width="*"/>
    					<ColumnDefinition Width="40"/>
    					<ColumnDefinition Width="20"/>
    				</Grid.ColumnDefinitions>
    				<Button x:Name="CloseButton" Content="Button" Grid.Column="2" Template="{DynamicResource CloseButtonTemplate}"/>
    				<TextBlock Text="{TemplateBinding Title}" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" Margin="4,4,0,4">
    					<TextBlock.Foreground>
    						<SolidColorBrush Color="{StaticResource Application_Dialog_Foreground}"/>
    					</TextBlock.Foreground>
    				</TextBlock>
    				<Border Grid.Column="1">
    					<Border.Background>
    						<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    							<LinearGradientBrush.RelativeTransform>
    								<TransformGroup>
    									<ScaleTransform CenterY="0.5" CenterX="0.5"/>
    									<SkewTransform CenterY="0.5" CenterX="0.5"/>
    									<RotateTransform Angle="270" CenterY="0.5" CenterX="0.5"/>
    									<TranslateTransform/>
    								</TransformGroup>
    							</LinearGradientBrush.RelativeTransform>
    							<GradientStop Color="{StaticResource Application_Dialog_HeaderAlphaBrush}"/>
    							<GradientStop Offset="1" Color="{StaticResource Application_Dialog_HeaderBrush}"/>
    						</LinearGradientBrush>
    					</Border.Background>
    				</Border>
    			</Grid>
    		</Border>
    		<Border BorderThickness="2">
    			<Border.Background>
    				<SolidColorBrush Color="{StaticResource Application_Dialog_Background}"/>
    			</Border.Background>
    			<Border.BorderBrush>
    				<SolidColorBrush Color="{StaticResource Application_Dialog_BorderBrush}"/>
    			</Border.BorderBrush>
    			<AdornerDecorator>
    				<ContentPresenter/>
    			</AdornerDecorator>
    		</Border>
    	</DockPanel>
	</ControlTemplate>
	
	<ControlTemplate x:Key="CloseButtonTemplate" TargetType="{x:Type Button}">
		<Grid Height="16" Width="16">
			<VisualStateManager.VisualStateGroups>
				<VisualStateGroup x:Name="CommonStates">
					<VisualStateGroup.Transitions>
						<VisualTransition From="Normal" GeneratedDuration="0:0:0.2" To="MouseOver"/>
						<VisualTransition From="MouseOver" GeneratedDuration="0:0:0.2" To="Normal"/>
					</VisualStateGroup.Transitions>
					<VisualState x:Name="Normal"/>
					<VisualState x:Name="MouseOver">
						<Storyboard>
							<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Dialog_CloseButton_Background_Move}"/>
							</ColorAnimationUsingKeyFrames>
							<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Dialog_CloseButton_BorderBrush_Move}"/>
							</ColorAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Pressed">
						<Storyboard>
							<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource Dialog_CloseButton_Background_Pressed}"/>
							</ColorAnimationUsingKeyFrames>
							<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path">
								<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Dialog_CloseButton_BorderBrush_Pressed}"/>
							</ColorAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Disabled"/>
				</VisualStateGroup>
			</VisualStateManager.VisualStateGroups>
			<Border>
				<Border.Background>
					<SolidColorBrush Color="{StaticResource Application_Dialog_HeaderBrush}"/>
				</Border.Background>
			</Border>
			<Path x:Name="path" Data="M1,0 L2,0 6,4 10,0 11,0 12,1 12,2 8,6 12,10 12,11 11,12 10,12 6,8 2,12 1,12 0,11 0,10 4,6 0,2 0,1 z" Margin="2" Stretch="Fill">
				<Path.Fill>
                    <SolidColorBrush Color="{StaticResource Dialog_CloseButton_Background}"/>
				</Path.Fill>
				<Path.Stroke>
                    <SolidColorBrush Color="{StaticResource Dialog_CloseButton_BorderBrush}"/>
				</Path.Stroke>
			</Path>
		</Grid>
	</ControlTemplate>
	<!-- Resource dictionary entries should be defined here. -->
</ResourceDictionary>